﻿using SymulatorEthernetWPF.SimObjects;
using SymulatorEthernetWPF.SimObjects.Layers.DataLink;
using System.Collections.ObjectModel;
using System.Windows;

namespace SymulatorEthernetWPF.UserInterface
{
    /// <summary>
    /// Interaction logic for ShowReceived.xaml
    /// </summary>
    public partial class ShowReceived : Window
    {
        private ObservableCollection<ReceivedData> _received = new ObservableCollection<ReceivedData>();
        private string deviceName;
        public ShowReceived(ObservableCollection<ReceivedData> received, string deviceName)
        {
            InitializeComponent();
            this.deviceName = deviceName;
            _received = received;
            received.CollectionChanged += received_CollectionChanged;
            foreach (ReceivedData it in received)
                ReceivedStack.Children.Add(new ReceivedDataItem(it));
        }

        void received_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            foreach(ReceivedData it in e.NewItems)
                ReceivedStack.Children.Add(new ReceivedDataItem(it));
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            this.Title += deviceName;
        }
    }
}
